package ipt.capitulo19;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
public class Cursor extends JPanel{
	JSlider barra;
	JTextArea casilla;
	JLabel lab;
	Cursor(double inicial, String m){
		lab=new JLabel(m);
		barra=new JSlider(JSlider.HORIZONTAL, -100, 100, (int)inicial);
		barra.addChangeListener(new VigilaCursor());
		casilla=new JTextArea(new Double(inicial).toString());
		setLayout(new FlowLayout(FlowLayout.LEFT));
		add(lab);
		add(barra);
		add(casilla);
	}
	class VigilaCursor implements ChangeListener{
		public void stateChanged(ChangeEvent e){
			double valor=(double)barra.getValue();
			casilla.setText(new Double(valor).toString());
		}
	}
}
